package Review;


public class Test12 {

	public static void main(String[] args) {
		print1ToN(1);
	}
    public static void print1ToN(int n){
    	if(n<=0){
    		return;
    	}
    	int[] array = new int[n];
    	for(int i=0;i<n;i++){
    		array[i] = 0;
    	}
    	while(add(array,n)){
    		print(array);
    	}
    }
    public static boolean add(int[] array,int n){
        int takeOver = 0;
    	for(int i=n-1;i>=0;i--){
    		int sum = array[i]+takeOver;
    		if(i==n-1){
    			sum++;
    		}
    		
    		if(sum>=10){
    			if(i==0){
    				return false;
    			}
    			else{
    				sum-=10;
    				array[i] = sum ;
        			takeOver = 1;
    			}
    			
    		}
    		else{
    			array[i] = sum;
    			break;
    		}
    	}
    	return true;
    }
    public static void print(int[] array){
    	int i=0;
    	for(i=0;i<array.length;i++){
    		if(array[i]!=0){
    			break;
    		}
    	}
    	while(i<array.length){
    		System.out.print(array[i++]);
    	}
    	System.out.print(" ");
    }
    
}
